﻿<EditForm Model="@TestModel" OnValidSubmit="@HandleValidSubmit" OnInvalidSubmit="@HandleInvalidSubmit">
    <DataAnnotationsValidator />

    <BitSearchBox IsEnabled="IsEnabled"
                  Immediate="Immediate"
                  Placeholder="@Placeholder"
                  @bind-Value="@TestModel.Value"
                  DisableAnimation="@DisableAnimation"
                  Underlined="@IsUnderlined"
                  AriaLabel="@AriaLabel"
                  DefaultValue="@DefaultValue"
                  FixedIcon="ShowIcon"
                  OnChange="HandleChange"
                  Autocomplete="@AutoComplete">
    </BitSearchBox>
</EditForm>

@code {
    [Parameter] public BitSearchBoxTestModel TestModel { get; set; } = new();
    [Parameter] public string? Placeholder { get; set; }
    [Parameter] public bool DisableAnimation { get; set; }
    [Parameter] public bool IsUnderlined { get; set; }
    [Parameter] public string? AriaLabel { get; set; }
    [Parameter] public string? DefaultValue { get; set; }
    [Parameter] public bool ShowIcon { get; set; }
    [Parameter] public bool IsEnabled { get; set; }
    [Parameter] public bool Immediate { get; set; }
    [Parameter] public string? AutoComplete { get; set; }

    public int CurrentCount { get; set; }
    public int ValidCount { get; set; }
    public int InvalidCount { get; set; }

    public void HandleChange(string e)
    {
        CurrentCount++;
    }

    private void HandleValidSubmit()
    {
        ValidCount++;
    }

    private void HandleInvalidSubmit()
    {
        InvalidCount++;
    }
}
